Solved

String literal vs String Object

Posted on 2003-11-27
3
199 Views
Last Modified: 2010-04-03
Hello experts,

Can you what is difference between String literal and String object? And the advantages & dis-advantages of both.

I know

s1 = "s1" //String Literal
s2 = new String("s2") //String object

But I don't know where to use what?

Thanks
0
Comment
Question by:mvkvivek
3 Comments
 
LVL 27

Accepted Solution

by:
negatyve earned 50 total points
ID: 9839526
==================================================
// try this code
s1 = "s1" //String Literal
s2 = new String("s2") //String object

trace("is s1 an instance of String Class? " + (s1 instanceof String))
trace("is s2 an instance of String Class? " + (s2 instanceof String))

trace("s1 datatype is " + (typeof s1))
trace("s2 datatype is " + (typeof s2))
==================================================

actually, the first is not generated from the String Class, and appears to be of "string" datatype.
the second is an instance of String Class, thus an object.
beside that, they behave the same (usually people use the first for brevity reasons)

(it's just like gotoAndPlay global function and gotoAndPlay Movieclip method)
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

The last time I worked with Flash and Socket connections was in AS1. A recent project required flash connecting to a Socket, and sending receiving information - we figured it would be easy enough - we all know about the socket policy documents and c…
I have found that much of my time doing support ends up being a constant repetition of the same steps to different people.  Early on I stated using web pages with Frequently Asked Questions (FAQs) to alleviate most of the burden.  Sometimes this jus…
The goal of the tutorial is to teach the user how to how to record live broadcast.
The goal of the tutorial is to teach the user what frame rate is, how to control it and what effect it has on the video.

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now