Found in old code
-
var fieldName = attributeVal.substring(0, attributeVal.length - 1);
It is javascript. :)
___ ___ ___
|__ |_| |\ | | |_| \ /
__| | | | \| |__| | | / -
var fieldName = attributeVal.substring(0, attributeVal.length - 1);
It is javascript. :)
___ ___ ___
|__ |_| |\ | | |_| \ /
__| | | | \| |__| | | / -
Why making things simple when you can over-complicate them? ;)
You always obtain more by being rather polite and armed than polite only.
-
var fieldName = attributeVal.substring(0, attributeVal.length - 1);
It is javascript. :)
___ ___ ___
|__ |_| |\ | | |_| \ /
__| | | | \| |__| | | / -
var fieldName = attributeVal.substring(0, attributeVal.length - 1);
It is javascript. :)
___ ___ ___
|__ |_| |\ | | |_| \ /
__| | | | \| |__| | | /Nice find. But what will happen when attributeVal is null?
-
Nice find. But what will happen when attributeVal is null?
Then run time error would occur. :) Actually null value is not a problem. The problem is, the style of assigning a string variable value to another variable. :)
___ ___ ___
|__ |_| |\ | | |_| \ /
__| | | | \| |__| | | / -
var fieldName = attributeVal.substring(0, attributeVal.length - 1);
It is javascript. :)
___ ___ ___
|__ |_| |\ | | |_| \ /
__| | | | \| |__| | | /How does it differ from JQuery?
I do not fear of failure. I fear of giving up out of frustration.
-
Nice find. But what will happen when attributeVal is null?
It's Javascript. You probably end up with fieldName == "undefine"... :rolleyes:
-
Then run time error would occur. :) Actually null value is not a problem. The problem is, the style of assigning a string variable value to another variable. :)
___ ___ ___
|__ |_| |\ | | |_| \ /
__| | | | \| |__| | | /Maybe the author wants the original string left unchanged? It is no longer an attribute value but now a fieldname so it makes sense to use a different variable? Have to admit, I don't really get this one :confused:
-
Maybe the author wants the original string left unchanged? It is no longer an attribute value but now a fieldname so it makes sense to use a different variable? Have to admit, I don't really get this one :confused:
Good catch. But there is nothing in code to keep string left unchanged.:) It was simple assignment. I think, first author had extract multiple values from the string but after some changes, the string was started giving single value. The second author may be don't want to change too much in code (specially substring function).:)
___ ___ ___
|__ |_| |\ | | |_| \ /
__| | | | \| |__| | | / -
var fieldName = attributeVal.substring(0, attributeVal.length - 1);
It is javascript. :)
___ ___ ___
|__ |_| |\ | | |_| \ /
__| | | | \| |__| | | /That allows for an easy performance improvement with V2.0 :-D
-
var fieldName = attributeVal.substring(0, attributeVal.length - 1);
It is javascript. :)
___ ___ ___
|__ |_| |\ | | |_| \ /
__| | | | \| |__| | | /What if he didn't want the original string reference ? not a bad way to clone
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L %^]*IRXD#@GKCQ`R\^SF_WcHbORY87֦ʻ6ϣN8ȤBcRAV\Z^&SU~%CSWQ@#2 W_AD`EPABIKRDFVS)EVLQK)JKQUFK[M`UKs*$GwU#QDXBER@CBN% R0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-iTV.C\y<pjxsg-b$f4ia>
----------------------------------------------- 128 bit encrypted signature, crack if you can
-
That allows for an easy performance improvement with V2.0 :-D
A real example of Weird and The Wonderful. :)
___ ___ ___
|__ |_| |\ | | |_| \ /
__| | | | \| |__| | | / -
var fieldName = attributeVal.substring(0, attributeVal.length - 1);
It is javascript. :)
___ ___ ___
|__ |_| |\ | | |_| \ /
__| | | | \| |__| | | / -
phil.o wrote:
Why making things simple when you can over-complicate them?
Because we are men, not women. :doh:
There are only 10 types of people in the world, those who understand binary and those who don't.
Casual sexism alert.
"If you don't fail at least 90 percent of the time, you're not aiming high enough." Alan Kay.
-
var fieldName = attributeVal.substring(0, attributeVal.length - 1);
It is javascript. :)
___ ___ ___
|__ |_| |\ | | |_| \ /
__| | | | \| |__| | | /Well,
substring
omits the character at the index specified by the second parameter, so the code you listed will return attributeVal with its final character removed. Maybe that's not what this code should be doing in this case, but what you showed isn't obviously incorrect. It's exactly the code you'd want to use to remove the last character of a string, althoughattributeVal.slice(0,-1)
would work in this case too. OTOH,
var fieldName = attributeVal.substring(0, attributeVal.length);
would be pointless, as it would just return
attributeVal
-
var fieldName = attributeVal.substring(0, attributeVal.length - 1);
It is javascript. :)
___ ___ ___
|__ |_| |\ | | |_| \ /
__| | | | \| |__| | | /Sanjay K. Gupta wrote:
It is javascript. :)
You don't say!
The language is JavaScript. that of Mordor, which I will not utter here
This is Javascript. If you put big wheels and a racing stripe on a golf cart, it's still a fucking golf cart.
"I don't know, extraterrestrial?" "You mean like from space?" "No, from Canada." If software development were a circus, we would all be the clowns. -
var fieldName = attributeVal.substring(0, attributeVal.length - 1);
It is javascript. :)
___ ___ ___
|__ |_| |\ | | |_| \ /
__| | | | \| |__| | | /That made my day. :laugh: :laugh:
Jeremy Falcon
-
What if he didn't want the original string reference ? not a bad way to clone
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L %^]*IRXD#@GKCQ`R\^SF_WcHbORY87֦ʻ6ϣN8ȤBcRAV\Z^&SU~%CSWQ@#2 W_AD`EPABIKRDFVS)EVLQK)JKQUFK[M`UKs*$GwU#QDXBER@CBN% R0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-iTV.C\y<pjxsg-b$f4ia>
----------------------------------------------- 128 bit encrypted signature, crack if you can
That only applies to objects. For instance...
var a = 'howdy';
var b = a;
a = 'partner';
alert(b); // shows howdyvar x = {message: 'howdy'};
var y = x;
x.message = 'partner';
alert(y.message); // shows partnerAnd even if that was the coder's intent, it would still be way more readable to do something like this...
var a = 'blah';
var b = new String(a);
a = 'yo';
alert(b); // shows blahJeremy Falcon