Zeriab

Huggins!
Veteran
Joined
Mar 20, 2012
Messages
1,278
Reaction score
1,444
First Language
English
Primarily Uses
RMXP
I know it's just a variable asignment in Javascript. But to me it's a method declaration and method declarations imo should not have semi-colons at the end.

Scene_MiniMap.prototype.initialize = function() { Scene_MenuBase.prototype.initialize.call(this); // << this one okay}; // << this one... Feels wrong. But if I leave it out, it could maybe in theory someday be interpreted wrongly...Damnit so I should put them behind every method as well then..
The automatic semicolon insertion rather means that the following structure should be avoided

Scene_MiniMap.prototype.initialize = function(){    Scene_MenuBase.prototype.initialize.call(this); // << this one okay}
Try playing around with this piece of code

Scene_MiniMap.prototype.playerCoords = function(){    return    {       "x": 2,       "y": 6    };}
Then compare it to this;

Scene_MiniMap.prototype.playerCoords = function(){    return {       "x": 2,       "y": 6    };}
*hugs*

 - Zeriab
 

DarknessFalls

Rpg Maker Jesus - JS Dev.
Veteran
Joined
Jun 7, 2013
Messages
1,393
Reaction score
210
First Language
English
i am so use to semicolons that not seeing one would make me say "code smell"
 

SilverDash

Veteran
Veteran
Joined
Oct 11, 2015
Messages
427
Reaction score
174
First Language
Dutch
Primarily Uses
RMMV
The automatic semicolon insertion rather means that the following structure should be avoided

Try playing around with this piece of code

Scene_MiniMap.prototype.playerCoords = function(){    return    {       "x": 2,       "y": 6    };}Then compare it to this;

Scene_MiniMap.prototype.playerCoords = function(){    return {       "x": 2,       "y": 6    };}*hugs*

 - Zeriab
Ugh I just had that. I only see it now :( . Made another topic for no reason. Anyway, I really dislike all those scripting languages. All so full of weird stuff and not strict enough. And I used to think that C# had some weird stuff. But the stuff I see in most scripting languages... Blergh

Honestly I stlil don't know how to write Javascript code lol. I just use my knowledge from other scripting languages. So far it works pretty well. Just these few weird things now and then that just... I have no words for...
 
Last edited by a moderator:

DarknessFalls

Rpg Maker Jesus - JS Dev.
Veteran
Joined
Jun 7, 2013
Messages
1,393
Reaction score
210
First Language
English
do "use strict" and youll see how strict this "scripting language" can get.
 

Tsukihime

Veteran
Veteran
Joined
Jun 30, 2012
Messages
8,564
Reaction score
3,862
First Language
English
I know it's just a variable asignment in Javascript. But to me it's a method declaration and method declarations imo should not have semi-colons at the end.

Scene_MiniMap.prototype.initialize = function() { Scene_MenuBase.prototype.initialize.call(this); // << this one okay}; // << this one... Feels wrong. But if I leave it out, it could maybe in theory someday be interpreted wrongly...Damnit so I should put them behind every method as well then..
Functions are first-class objects in Javascript, so you're not just declaring a method, you're also assigning it to a variable.

So yes, if you were *only* defining a method, then I wouldn't add a semi-colon...

I don't think it would be problematic if I omitted semi-colons in functions like these

Code:
function myFunc() {  return 1;}
But this is a different story
Code:
myFunct = function() {  return 1;};
 
Last edited by a moderator:

SilverDash

Veteran
Veteran
Joined
Oct 11, 2015
Messages
427
Reaction score
174
First Language
Dutch
Primarily Uses
RMMV
@Tsukihime

Yes I know the variable-assignment is the difference. But creating functions by assigning new objects to variables already feels wrong to me. I mean I can live with it all, I will add semicolons to them. But it just feels wrong somehow. But that's just personal I guess.

do "use strict" and youll see how strict this "scripting language" can get.
Impossible, Javascript will still not tell me when: I missed a semicolon, I misspelled a variable name or when my string ends up as NaN because of an undefined value somewhere 'far away'...

It will never be strict because JS simply is not strict. You can't expect the programmer to be strict, that would defeat the whole purpose of a strict language I think. Like blaming the coders for making the mistake of writing "folderpath" instead of "folderPath" and then ending up with an undefined value in some function many iterations later on the stack. I always love languages that just crash the moment I use an undeclared variable or forget a semicolon.

But yes I will add semicolons all over the place now :D
 
Last edited by a moderator:

DarknessFalls

Rpg Maker Jesus - JS Dev.
Veteran
Joined
Jun 7, 2013
Messages
1,393
Reaction score
210
First Language
English
thats because strict doesn't care about semicolons. It does care about you doing x = y when you should be doing var x =y amount other things.
 

JahwsUF

Veteran
Veteran
Joined
Oct 25, 2015
Messages
65
Reaction score
104
First Language
English
@Tsukihime

Yes I know the variable-assignment is the difference. But creating functions by assigning new objects to variables already feels wrong to me. I mean I can live with it all, I will add semicolons to them. But it just feels wrong somehow. But that's just personal I guess.

Impossible, Javascript will still not tell me when: I missed a semicolon, I misspelled a variable name or when my string ends up as NaN because of an undefined value somewhere 'far away'...

It will never be strict because JS simply is not strict. You can't expect the programmer to be strict, that would defeat the whole purpose of a strict language I think. Like blaming the coders for making the mistake of writing "folderpath" instead of "folderPath" and then ending up with an undefined value in some function many iterations later on the stack. I always love languages that just crash the moment I use an undeclared variable or forget a semicolon.

But yes I will add semicolons all over the place now :D
As someone who's predominantly a C++ and Java developer, I feel you.  If you think that feels wrong, it feels even worse when you overwrite a built-in method with your own version.  (That's incredibly against proper design principles in industry languages.)  It also feels incredibly wrong explicitly assigning to the "this" parameter of another function when binding/calling it.  That being stated, both have actually been incredibly useful for plugin development.

And yeah, it'd be nice to have a "strict" mode in Javascript, to be sure.
 
Last edited by a moderator:

SilverDash

Veteran
Veteran
Joined
Oct 11, 2015
Messages
427
Reaction score
174
First Language
Dutch
Primarily Uses
RMMV
I just found this: http://www.w3schools.com/js/js_strict.asp

So there is a strict mode.. It works but sadly it doesn't crash. But atleast it shows an error in the console. And this strict-mode is still limited but better than nothing.
 
Last edited by a moderator:

Latest Threads

Latest Posts

Latest Profile Posts

Anybody know how to make an enemy have a line of sight? I'm trying to make Persona-like enemies.
zomboars.jpg

Concept art

Zomboars- main enemies in my story
mutant pigs addicted to beer
SF_People1_3 added!
index.php

I haven't been on here in forever wow(missed my forum birthday T-T). Anyways, I'm dabbling in BGMs, here's something I'm actually willing to share.

Forum statistics

Threads
109,203
Messages
1,043,018
Members
141,711
Latest member
DamonAngel04
Top