opensas
opensas

Reputation: 63415

Why is jslint reporting Unexpected 'variable'

I have the following code

/*globals define,console*/
define(
  function(param) {
    'use strict';
    var v1 = v1 || {};
    console.log(v1);
  }
);

and jslint reports:

jslint:accessibility2.js:5:18:Unexpected 'v1'.

jslint: ignored 0 errors.

I wonder why jslint doesn't like the var v1 = v1 || {}; stuff?

Upvotes: 0

Views: 1140

Answers (1)

yunzen
yunzen

Reputation: 33439

var v1; 
v1 = v1 || {};

Should do the trick.
Why?
You use the v1 on the right side before you declare it on the left side.

Upvotes: 2

Related Questions