मान लीजिए निम्नलिखित हमारा ऐरे है जिसमें एलिमेंट्स + साइन से शुरू होते हैं -
var studentNames = [ '+John Smith', '+David Miller', '+Carol Taylor', '+John Doe', '+Adam Smith' ];
+ साइन हटाने के लिए, कोड इस प्रकार है -
उदाहरण
studentNames = [
'+John Smith',
'+David Miller',
'+Carol Taylor',
'+John Doe',
'+Adam Smith'
];
console.log("The actual array=");
console.log(studentNames);
studentNames = studentNames.map(function (value) {
return value.replace('+', '');
});
console.log("After removing the + symbol, The result is=");
console.log(studentNames);उपरोक्त प्रोग्राम चलाने के लिए, आपको निम्नलिखित कमांड का उपयोग करना होगा -
node fileName.js.
यहां मेरा फ़ाइल नाम demo205.js है।
आउटपुट
यह निम्नलिखित आउटपुट देगा -
PS C:\Users\Amit\javascript-code> node demo205.js The actual array= [ '+John Smith', '+David Miller', '+Carol Taylor', '+John Doe', '+Adam Smith' ] After removing the + symbol, The result is= [ 'John Smith', 'David Miller', 'Carol Taylor', 'John Doe', 'Adam Smith' ]