Tag: comma

JavaScript: comma after opening bracket of parameter in syntax example

The syntax for methods such as Array.prototype.indexOf() look like this: arr.indexOf(searchElement[, fromIndex = 0]) What does [, …] mean, and why is the comma inside of the brackets?

What does return void 0 === i && (i = 3), 0 === i ? ( ..A.. ) : ( ..B.. ) do?

I came to this code but I don’t understand very well what it does.. test.update = function(i) { return void 0 === i && (i = 3), 0 === i ? (..A..) : (..B..) } (..A..) and (..B..) are just other lines of code I haven’t posted. Let’s say if i would have a 0 […]

Aptana complaining about JavaScript semicolons

Why does Aptana with either validator (Mozilla or JSlint) complain about this code: var collectionOfValues = { key0 : value0; key1 : value1; key2 : value2; }; It works fine with , but not with ; Even code from The Good Parts won’t validate: var myObject = { value: 0; increment: function (inc) { this.value […]

Regex Comma Separated Emails

I am trying to get this Regex statement to work ^([_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})+(\s?[,]\s?|$))+$ for a string of comma separated emails in a textbox using jQuery(‘#textbox’).val(); which passes the values into the Regex statement to find errors for a string like: “test@test.com, test1@test.com,test2@test.com” But for some reason it is returning an error. I tried running it through http://regexpal.com/ […]

Javascript validate list of email addresses comma separated

I am using ServiceNow and I need to validate a textbox that will accept a list of email addresses that are separated by commas. The list of email addresses is in the variable group_members. The validation works for the first email address only. The second email address in the list is showing as invalid even […]

Add commas to a javascript countup timer

Here is my program: <script> var montharray = new Array(“Jan”, “Feb”, “Mar”, “Apr”, “May”, “Jun”, “Jul”, “Aug”, “Sep”, “Oct”, “Nov”, “Dec”) function countup(yr, m, d) { var today = new Date() var todayy = today.getYear() if (todayy < 1000) todayy += 1900 var todaym = today.getMonth() var todayd = today.getDate() var todaystring = montharray[todaym] + […]

Add a comma to the end of each line using php

I am having a csv file with 1 email id in each line. I want to add comma after each email id. I want to add a comma to the end of each line using php. How can i do this? Is there a particular function for that? UPDATE I want this so that I […]

Javascript: Joining two strings with a comma and space between them

So i’m new to javascript and this is what i need to do: I have been given the two strings “str1” and “str2” and i need to join them into a single string. The result should be something like this “String1, String 2”. The “str1” and “str2” variables however does not have the “, “. […]

Use of commas versus semicolons in JavaScript?

Given the following code var fn = function () { var x = ‘x’, y = ‘y’; this.a = ‘a’, this.b = ‘b’, this.c = ‘c’; this.d = ‘d’, this.e = ‘e’; } You can see that there is a mix of both. What would be the benefit of using one or the other? My […]