Solved

String literal vs String Object

Posted on 2003-11-27
3
200 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Recently, I was asked to recommend a tracking system to be implemented on a clients website. As the entire site was built on flash, my first thought was to suggest custom built tracking system. However, our company at that point of time didn't h…
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…
In this tutorial viewers will learn how to create a basic shape tween animation in Flash including shape hints for smooth animation Open a new document in Flash: Draw a shape: Select another frame (how long you want the tween to be): Right click and…
The goal of the tutorial is to teach the user how to how to record live broadcast.

914 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

21 Experts available now in Live!

Get 1:1 Help Now