Theme Layout

Boxed or Wide or Framed

Wide

Theme Translation

Display Featured Slider

Featured Slider Styles

Display Grid Slider

yes

Grid Slider Styles

Display Trending Posts

Display Author Bio

Display Instagram Footer

off

Dark or Light Style

Light

Blog Archive

Powered by Blogger.

Saturday, February 11, 2017

[JavaScript] Strings


# JavaScript Objects


● JavaScript Strings.

 A JavaScript string simply stores a series of characters like "Komorebi".
 A string can be any text inside quotes. I can use single or double quotes.

 I can use quotes inside a string, as long as they don't match the quotes surrounding like  below example code.


● String Length.

 The length of a string is found in the built in property length.

● Special Characters

 Because strings must be written within quotes, JavaScript will misunderstand below string.
 < var x = "We are called "Vikings" from America. ">
The String will be chopped to "We are called".
The solution to avoid this problem, is to use the \ escape character.
The backslash escape character turns special characters into string characters.


The escape character (\) can also be used to insert other special characters in a string.
These are commonly used special characters that can be inserted in a text with the backslash sign.


Five other escape characters are valid in JSP.


The escape characters above were originally designed to control typewriters, teletypes, and fax machines. They don't make any sense in HTML.

● Breaking Long Code Lines.

 For best readability, programmers often like to avoid code lines longer than 80 characters.
 If a JSP statement does not fit on one line, the best place to break it is after an operator.


but I can not break up a code line within a text string with a single backslash.
The \ method is not the preferred method. It might not have universal support.
Some browsers do not allow spaces behind the \ character.

● Strings Can be Objects.

 Normally, JSP strings are primitive values, created from literals.
  var Name="Komorebi"

But strings can also be defined as objects with the keyword new. 
  var Name = new String("Komorebi")





QuickEdit
Unknown
0 Comments
Share This Post :

You Might Also Like

No comments:

Post a Comment

Follow @SunriseSunsetBlog