Skip to content

ThirteeNov

My personal blog about coding and internet

Menu
  • About me
  • About Zofia Kreasi
  • Cart
  • Checkout
  • Making an airplane game from scratch in Unity
  • My account
  • Privacy Policy
  • Privacy Policy – zkLeaderboard
  • Sample Page
  • Shop
  • Tutorials on Learning JavaScript
  • ZKAccounts – Privacy Policy
Menu

Easy JavaScript Tutorial: Splitting a string with JavaScript

Posted on August 6, 2017August 4, 2020 by Habibie

When we create a variable in JavaScript with string value, in fact this variable contains arrays, each string character inside one array element.

For example, let’s create a string variable var myString = "Hello!";. Then if you run this code: myString.length it will return “6” as it’s value, that means that variable contains 6 array elements, which is 6 characters.

There is built in function we can use to split a string into several parts depends on our need. For example, let’s create this variable var newString = "Hello, world!";. Now we want to split that “Hello, world!” into two parts “Hello” and “world!” (separated by “,”). What we’re going to do is to use this built in function: newString.split(","); and what happens next is that variable now contains two array elements, first “Hello” and the second ” world!” (with white space, of course).

Watch the tutorial here:

Post Views: 430
ciihuy2020

Welcome!

  • My YouTube Channel
  • My GitHub Page
  • About me

Categories

  • 3DVista
  • Android
  • Apache
  • C#
  • Cordova
  • Electron & Node JS
  • HTML5, CSS & JavaScript
  • iOS
  • Let's Make Unity Games
  • Misc
  • Photoshop
  • PHP
  • Python
  • Uncategorized
  • Unity
  • WordPress

Recent Posts

  • Hover Reveal script for Unity to show and hide object on mouse hover
  • How to Prevent UI Clicks in Unity from “Bleeding Through” to 3D Objects Behind Them
  • Make objects like wires and cables easily in Unity using Ciihuy Curved Mesh
  • [SOLVED] Can’t Add Custom Domain to Blogger After Losing CNAME Verification
  • iOS App Icon Generator by CiihuyCom
© 2026 ThirteeNov | Powered by Superbs Personal Blog theme