Talk:Core JavaScript 1.5 Reference:Global Objects:String:substr
From MDC
[edit] Should print change to other name?
Because print conflicts with window.print in some browsers, should print change to other name? The following code is a example.:
//assumes a echo function is defined.
var str = "abcdefghij";
echo("(1,2): " + str.substr(1,2));
echo("(-2,2): " + str.substr(-2,2));
echo("(1): " + str.substr(1));
echo("(-20, 2): " + str.substr(-20,2));
echo("(20, 2): " + str.substr(20,2));
--Potappo 04:39, 16 March 2007 (PDT)
- I sympathize with the desire, but I don't think it's that huge a deal in practice. I don't think a beginning web developer is likely to assume a
print()function is defined; also, it's not a huge jump to do something likevar print = alert;to make the examples work. Also, the use ofprintis reasonably standard -- Perl, Python, and PHP all have a construct namedprintthat does basically what's done by the hypotheticalprintfunction used here -- so I don't see a huge gain from switching to something else. --Waldo 12:33, 18 March 2007 (PDT)- Thanks for reply. I understand your idea, and I might think too much, so I don't change
printto other name. -- Potappo 06:02, 19 March 2007 (PDT)
- Thanks for reply. I understand your idea, and I might think too much, so I don't change