Get Cursor Position, Line & Column

How do I get the cursor position?

I created this thread because I didn’t find a post about this.
This is a solution I found.

let head = this._codemirror.state.selection.main.head;
		let cursor = this._codemirror.state.doc.lineAt(head);
		let line = cursor.number;
		let col = head - cursor.from;
		console.log("line = " + line + " col = " + col);