?
Solved

String literal vs String Object

Posted on 2003-11-27
3
Medium Priority
?
207 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 200 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

Introduction This article is primarily concerned with ActionScript 3 and generally specific to AVM2.  Most suggestions would apply to ActionScript 2 as well, and I've noted those tips that differ between AS2 and AS3. With the advent of ActionS…
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…
The goal of the tutorial is to teach the user how to how to load their YouTube profile onto Flash Media Live Encoder.
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.
Suggested Courses
Course of the Month11 days, 18 hours left to enroll

752 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