[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

String literal vs String Object

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This is intended to introduce all collision detection principles in flash, their strengths, weaknesses and workarounds. The main method for Collision Detection in flash is using hitTestObject. But unless you'll be pushing rectangular shapes without …
In my long career of working as an actionscript developer, I had spent sleepless night often working hard to solve some small problems which actually took a lot of my development time; later found out the solutions to be a line or two. Here are s…
In this tutorial viewers will learn how to create a basic motion tween animation in Flash Open a new document in Flash: Draw/import an image: Press CTRL + F8 to convert it into a graphic symbol: Select a frame (how long you want the tween to last): …
The goal of the tutorial is to teach the user how to how to record live broadcast.
Suggested Courses

656 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