get the length of a string in js code example Example: length of string in javascript var str = "Hello World!"; var n = str.length;