dragan Posted September 7, 2019 Share Posted September 7, 2019 Putting "use strict" should really be the default... It simply shows more hints and errors and this can be very useful while debugging. Using this in every JS file now revealed some data type mismatch too, when using !=== instead of !==. (see screenshots below) In trash.js I changed basically these lines: var gridInstance = $('.RockTabulator.tabulator'); var grid = RockTabulator.getGrid(gridInstance); and further below: // success if(result.success) { UIkit.notification(check + result.success, {timeout: 3000}); if( RockTabulator.getGrid(gridInstance).reload() ) { console.log('grid has reloaded!'); } else { console.log('grid has not reloaded!'); } // grid.reload(); } }, But as I said, since RT is not known inside that JS script, it can't call an unknown method getGrid... 1 Link to comment Share on other sites More sharing options...
bernhard Posted September 8, 2019 Author Share Posted September 8, 2019 19 hours ago, dragan said: when using !=== instead of !==. (see screenshots below) I don't understand what you mean. I also don't get all the errors shown in your screenshot. Or at least I don't know when they occur. Maybe you could do a short screencast? I'm working on the subdir fix now... Link to comment Share on other sites More sharing options...
bernhard Posted September 8, 2019 Author Share Posted September 8, 2019 Now guess what @dragan ... I've changed nothing in my code. Just pulled the changes for the not supported subdir installations and everything just WORKS! ? Link to comment Share on other sites More sharing options...
dragan Posted September 8, 2019 Share Posted September 8, 2019 @bernhard Perhaps go back to page 1 of this thread, i.e. this post. a) I have inserted in all JS files "use strict" at the very top b) I have replaced != with !== everywhere the IDE was warning me tldr; "use strict" in JS is something like PW's debug mode enabled: it gives you many more errors, hints + warnings that otherwise would slip through (even if you end up with unexpected results). The Mozilla link I posted is a good read. Link to comment Share on other sites More sharing options...
dragan Posted September 8, 2019 Share Posted September 8, 2019 7 minutes ago, bernhard said: Just pulled the changes for the not supported subdir installations and everything just WORKS! Great news! At least one ray of sunshine on this rainy miserable day ? Link to comment Share on other sites More sharing options...
bernhard Posted September 8, 2019 Author Share Posted September 8, 2019 28 minutes ago, dragan said: @bernhard Perhaps go back to page 1 of this thread, i.e. this post. a) I have inserted in all JS files "use strict" at the very top b) I have replaced != with !== everywhere the IDE was warning me Thx, I've read all your posts and links. "use strict" atm breaks my module. I'll have a look into that. I don't see any harm in using != instead of !== wherever I'm using it, but if you can explain why it should be a problem I'm happy to learn and change it. Link to comment Share on other sites More sharing options...
bernhard Posted September 8, 2019 Author Share Posted September 8, 2019 22 hours ago, dragan said: Yep: you should get used to use "use strict" in every JS file, then you would have found this error earlier: https://developer.mozilla.org/de/docs/Web/JavaScript/Reference/Strict_mode Voila ? https://github.com/BernhardBaumrock/RockTabulator/commit/6920de2120ade50099e269b6fa025acc98659d8a Link to comment Share on other sites More sharing options...
uniqu3 Posted September 9, 2019 Share Posted September 9, 2019 18 hours ago, dragan said: @bernhard Perhaps go back to page 1 of this thread, i.e. this post. a) I have inserted in all JS files "use strict" at the very top b) I have replaced != with !== everywhere the IDE was warning me tldr; "use strict" in JS is something like PW's debug mode enabled: it gives you many more errors, hints + warnings that otherwise would slip through (even if you end up with unexpected results). The Mozilla link I posted is a good read. @bernhard the != or == comparison operator will simply check for a value no matter of the type in example checking against 1, '1', or true will always return true, whereas triple comparison operator will also check for type, therefore if a variable value was set to like var a = 1; checking against boolean like if(a === true) will return false because value of variable a is actually integer. It's best practice using triple comparison operator but it also depends on situation if in example the type of value you are checking against is always known and you always expect it to be the same. 1 Link to comment Share on other sites More sharing options...
bernhard Posted September 9, 2019 Author Share Posted September 9, 2019 Thx for the explanation. I'm aware of that, but my question was more if there is a good reason in this special case why I should use !== instead of != I tend to use !== whenever it is NECESSARY (eg when doing strpos where a 0 is something different than FALSE) and != whenever it is not necessary. That way I know instantly that the type matters... PS: Welcome to the forum ? 1 Link to comment Share on other sites More sharing options...
szabesz Posted September 9, 2019 Share Posted September 9, 2019 (edited) 6 hours ago, bernhard said: I tend to use !== whenever it is NECESSARY I do the opposite: I tend to use != and == when it is necessary, eg. when we are expecting multiple types and coercing can be harvested as a lazy programmer's tool ? Remebering what != and == do can be a challenge: https://dorey.github.io/JavaScript-Equality-Table/ Edited September 9, 2019 by szabesz typo 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now