Use strict



I'm just learning javascript and looking for advice on how to use 'use strict' and the readline function.

When I add 'use strict' to the top of the code, a warning icon shows up on the lines which use readline(). Message says 'readline is not defined'. But code works.

I change the readline() calls to this.readline() and the messages changes to 'possible strict violation'

'use strict'
var N = parseInt(this.readline());

What's the correct way to do this using 'use strict'?
I searched spider monkey and google and couldn't find an answer.



The warnings in the IDE comes from eslint. readline is a global variable injected by SpiderMonkey. Since eslint doesn't know how to behave in a SpiderMonkey environment, you'll have to tell him.

/* global readline */
'use strict';

let n = Number(readline());

The possible strict violation comes from the fact that you are using this outside a function. So eslint tells you that this may be not defined.


Thanks for the reply and the info! I appreciate it.