Create shortcut to console.log() in Chrome

后端 未结 4 867
臣服心动
臣服心动 2020-11-28 12:34

Because I\'m lazy, I created a function log that basically is just an abbreviation of console.log:

function log() {
  console.log.a         


        
相关标签:
4条回答
  • 2020-11-28 13:11

    When I reported it, it was refused but the answer was simple - create the shortcut like this:

    var log = console.log.bind(console);
    

    This doesn't leave out the line number, whilst you can call it like log(...).

    0 讨论(0)
  • 2020-11-28 13:17

    I just created a module to do that.

    Check out: https://github.com/ahlechandre/consl

    Install

    npm install consl --save-dev

    Usage

    const { cl } = require('consl');
    
    cl('Outputs a message on the Console using a quick');
    
    0 讨论(0)
  • 2020-11-28 13:18

    In my case I've set up an AutoHotKey shortcut with Ctrl + Alt + L as below:

    ^!l::Send console.log();{Left}{Left}
    

    The good thing is it brings the cursor back inside the brackets for quick typing.

    0 讨论(0)
  • 2020-11-28 13:20

    Tried a few things, but I don't think you can do this. As soon as you wrap console.log, the line nr will be the line where this wrap is to be found in the code. I suppose we have to live with that then?

    0 讨论(0)
提交回复
热议问题