/    Sign up×
Community /Pin to ProfileBookmark

javascript string object

how we give a value to the following property of string object

document.getElementById(‘id’).style.backgroundImage =

to post a comment
JavaScript

10 Comments(s)

Copy linkTweet thisAlerts:
@rnd_meOct 08.2009 — i dont see a string object...
Copy linkTweet thisAlerts:
@PprakashauthorOct 09.2009 — object means just like as class. it have some properties and methods.

ex:- string object have property "lenght".

try this alert("this is tesst".length);


put any string in the delimits of double quotes and then test/
Copy linkTweet thisAlerts:
@KorOct 09.2009 — Some properties are read only. [B]length[/B] is one of them. You can not give them values, you can only [I]read[/I] their values.
Copy linkTweet thisAlerts:
@rnd_meOct 10.2009 — i think you might be referring to prototype properties, which include methods.

for example:


[CODE]String.prototype.vowelCount=function(){
return (this.match(/[aeiou]/ig)||[]).length;
}



alert( "hello world".vowelCount() ) //==3[/CODE]
Copy linkTweet thisAlerts:
@PprakashauthorOct 10.2009 — which of the read only prototypes, which are not. how can we guss.
Copy linkTweet thisAlerts:
@rnd_meOct 10.2009 — which of the read only prototypes, which are not. how can we guss.[/QUOTE]

i think that very few are read-only, constructor, prototype, and length on arrays and strings are the big ones...


most of the ones listed here can, but [B]should not [/B]be redefined, or it can cause portability problems between scripts.

http://www.w3schools.com/jsref/jsref_obj_string.asp

http://www.w3schools.com/jsref/jsref_obj_array.asp
Copy linkTweet thisAlerts:
@PprakashauthorOct 11.2009 — some methods we can develop and then use

ex:-

first prepare the following method

String.prototype.trim = function() {return this.replace(/^s+|s+$/g,"");};

now the method trim is avialble

vat t =" this is ram ";


document.write(t+"<hr/>");


t = t.trim();

document.write(t+"<hr/>");

observe before and after using the method trim().


i want to develop theis type of methods. this is useful?
Copy linkTweet thisAlerts:
@rnd_meOct 12.2009 — some methods we can develop and then use

observe before and after using the method trim().

i want to develop theis type of methods. this is useful?[/QUOTE]



yes, i like them a lot.

the Prototype library has many.

i list a bunch i wrote here: http://danml.com/pub/protodoc.htm

they should all be somewhere in http://danml.com/pub/jmod.js


one complaint about prototype methods is that they create globals to the right of a dot.

To overcome this, i wrote the OO library a while back.

you can pluck some methods or just steal some ideas from here:

http://danml.com/pub/lib/oobuilder.htm

http://danml.com/pub/lib/ooapi.htm#setStyle


this lets you put many protos into a single spot, and selectively upgrade specific objects, rather than whole types at once.
Copy linkTweet thisAlerts:
@PprakashauthorOct 14.2009 — hello, "rnd me"

you are done a great job

i visted your sites:

http://danml.com/pub/lib/oobuilder.htm
http://danml.com/pub/lib/OOapi.htm


its excellent work.

i want to participitate in this. i also made some new methods and properties. how was i add them to u.
Copy linkTweet thisAlerts:
@rnd_meOct 15.2009 — hello, "rnd me"

you are done a great job

i visted your sites:

http://danml.com/pub/lib/oobuilder.htm
http://danml.com/pub/lib/OOapi.htm


its excellent work.

i want to participitate in this. i also made some new methods and properties. how was i add them to u.[/QUOTE]


I'd like to see what you have, i'm always looking for new protos.

you can private message me now, i cleaned up my 100% full inbox just today...
×

Success!

Help @Pprakash spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...