Murali Murali - 1 month ago 5
AngularJS Question

Get specific key value in a string

var a = "Welcome to angular js";


I am using split() function its return array

console.log(a.split(" "));


but i don't need array, i want only 'angular' word



var a = "welcome to angular js"
console.log(a.split(" "));

<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.22/angular.min.js"></script>





Any one help me here?

Answer

Try this code,

var a = "welcome to angular js"

console.log(a.split(" ")[2]);