Solved

String literal vs String Object

Posted on 2003-11-27
3
206 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

I have been doing hardcore actionscripting for some time; and needless to say I have faced a lot of problems in just understanding others' code rather than understanding what the code executes. A programmer's life can become hell when there are a lo…
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…
The goal of the tutorial is to teach the user how to use the auto adjust feature and what the different options do. When your video is not working right you can choose the auto adjust feature to help choose your settings.
This Micro Tutorial will teach to how to utilize bit rate in Adobe Flash Media Live Encoder.

688 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