undefined|0|ReferenceError: Strict mode forbids implicit creation of global property 'csrf_token'

前端 未结 1 491
耶瑟儿~
耶瑟儿~ 2020-12-19 00:12

So, this was quite an interesting problem I have been running into.

I am currently building a backbone.js - Rails app. Generally just building this for learning purp

相关标签:
1条回答
  • 2020-12-19 01:07

    It is telling you that a value is being assigned to a variable called csrf_token that has not been declared, e.g.

    csrf_token = 'foo';
    

    In non–strict mode, that will create a property of the global object (usually called a global variable) called csrf_token when that line of code is executed.

    In strict mode, it will throw the error you see because strict mode prevents the implicit creation of global variables. You could also fix it by including:

    var csrf_token;
    

    anywhere in a global context in the same script element as the code the error comes from, or a previous script element.

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