Hey! Thanks to you I made something!! A regex to detect uncommented console.log()!! What do you think?
const regEx = /^(?!.*\/\/)(?=.*console\.log)/g const examples = [ ' // console.log("asdf")', ' // console.log("asdf")', ' // console.log("asdf")', ' console.log("asdf") ', ' console.log(', ] examples.forEach( (example) => { console.log( example, example.match(regEx) !== null ) } )
And the output:
// console.log("asdf") false // console.log("asdf") false // console.log("asdf") false console.log("asdf") true console.log( true
That's pretty cool! I imagine something like this would be useful to comment console.logs once you're done debugging.
console.log
Your next goal is to get it to work with these :)
console.log("foo"); // console.log("bar"); /***** * console.log("baz"); *****/ console.table(['foo', 'bar']);
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Hey! Thanks to you I made something!! A regex to detect uncommented console.log()!! What do you think?
And the output:
That's pretty cool! I imagine something like this would be useful to comment
console.log
s once you're done debugging.Your next goal is to get it to work with these :)