Click here to Skip to main content
15,890,512 members

The Insider News

   

The Insider News is for breaking IT and Software development news. Post your news, your alerts and your inside scoops. This is an IT news-only forum - all off-topic, non-news posts will be removed. If you wish to ask a programming question please post it here.

Get The Daily Insider direct to your mailbox every day. Subscribe now!

 
GeneralRe: Amazon will abandon plans to build second headquarters in New York Pin
Roland M Smith14-Feb-19 8:39
Roland M Smith14-Feb-19 8:39 
GeneralRe: Amazon will abandon plans to build second headquarters in New York Pin
Mark_Wallace14-Feb-19 12:41
Mark_Wallace14-Feb-19 12:41 
NewsCan Amazon, Facebook, Google be tamed by being forced to share their data? Pin
Kent Sharkey14-Feb-19 7:16
staffKent Sharkey14-Feb-19 7:16 
GeneralRe: Can Amazon, Facebook, Google be tamed by being forced to share their data? Pin
Mark_Wallace14-Feb-19 12:37
Mark_Wallace14-Feb-19 12:37 
GeneralRe: Can Amazon, Facebook, Google be tamed by being forced to share their data? Pin
Dan Neely15-Feb-19 2:26
Dan Neely15-Feb-19 2:26 
Newsrecent Jon Skeet post on C# 8 Nullable directive and attrbute Pin
BillWoodruff13-Feb-19 16:53
professionalBillWoodruff13-Feb-19 16:53 
GeneralRe: recent Jon Skeet post on C# 8 Nullable directive and attrbute Pin
Marc Clifton14-Feb-19 2:36
mvaMarc Clifton14-Feb-19 2:36 
GeneralRe: recent Jon Skeet post on C# 8 Nullable directive and attrbute Pin
raddevus14-Feb-19 10:33
mvaraddevus14-Feb-19 10:33 
Marc Clifton wrote:
A null int would be expressed as an empty array [] whereas an int with a value would be expressed as a single item array [42]

That's amazing! I just wrote some JavaScript code that allows you to query any list of objects for any property's value and I decided to always return an array : that way you always look for the same thing -- the length of the array. If it's 0 then you have no result-list and it's >= 1 then you know you have at least one.

JavaScript
selectItems(propertyName, arrayOfItems, propertyValue){
// #### Get the object(s) 
// #### from the arrayOfItems
// #### where value of propertyName is equal to the propertyValue
// #### Returns an array of 0 or more items
var outItems = [];
for (var x = 0; x < arrayOfItems.length; x++){
//console.log("arrayOfItems[x][idPropertyName] : " + arrayOfItems[x][idPropertyName]);
	   if (propertyValue === undefined){
                // this is a cheat to allow me to get a subset of all the objects when I don't 
                // care what the propertyValue is.    If you call the method with no 3rd param
                // it will run this code
		outItems.push(arrayOfItems[x]);
   	   }
   	   if (arrayOfItems[x][propertyName] === propertyValue){
		//console.log(arrayOfItems[x][propertyName]);
		outItems.push(arrayOfItems[x]);
	   }
	}
	return outItems;
}


You can think of it as :
select propertyName from arrayOfItems where propertyValue = "yourvalue"
This is one place where JavaScript is very cool, because you can reference the propertyName via array brackets. Thumbs Up | :thumbsup:
Of course I wrote other methods that allow you to get an array of values also (instead of an array of the target objects).
Always Return an Array!
Anyways, the cool thing is that I thought it seemed most elegant to always return an array also.
GeneralRe: recent Jon Skeet post on C# 8 Nullable directive and attrbute Pin
BillWoodruff14-Feb-19 15:17
professionalBillWoodruff14-Feb-19 15:17 
GeneralRe: recent Jon Skeet post on C# 8 Nullable directive and attrbute Pin
raddevus15-Feb-19 1:42
mvaraddevus15-Feb-19 1:42 
GeneralRe: recent Jon Skeet post on C# 8 Nullable directive and attrbute Pin
Rob Grainger17-Feb-19 23:44
Rob Grainger17-Feb-19 23:44 
GeneralRe: recent Jon Skeet post on C# 8 Nullable directive and attrbute Pin
Marc Clifton15-Feb-19 4:46
mvaMarc Clifton15-Feb-19 4:46 
GeneralRe: recent Jon Skeet post on C# 8 Nullable directive and attrbute Pin
BillWoodruff14-Feb-19 15:11
professionalBillWoodruff14-Feb-19 15:11 
GeneralRe: recent Jon Skeet post on C# 8 Nullable directive and attrbute Pin
Marc Clifton15-Feb-19 4:45
mvaMarc Clifton15-Feb-19 4:45 
GeneralRe: recent Jon Skeet post on C# 8 Nullable directive and attrbute Pin
BillWoodruff16-Feb-19 13:25
professionalBillWoodruff16-Feb-19 13:25 
NewsResearchers develop a new system to detect abuse in online communities Pin
Kent Sharkey13-Feb-19 11:16
staffKent Sharkey13-Feb-19 11:16 
GeneralRe: Researchers develop a new system to detect abuse in online communities Pin
Nelek13-Feb-19 19:00
protectorNelek13-Feb-19 19:00 
GeneralRe: Researchers develop a new system to detect abuse in online communities Pin
Mark_Wallace13-Feb-19 21:20
Mark_Wallace13-Feb-19 21:20 
GeneralRe: Researchers develop a new system to detect abuse in online communities Pin
Eddy Vluggen14-Feb-19 1:58
professionalEddy Vluggen14-Feb-19 1:58 
GeneralRe: Researchers develop a new system to detect abuse in online communities Pin
Dan Neely14-Feb-19 2:42
Dan Neely14-Feb-19 2:42 
NewsDirty_Sock vulnerability in Canonical's snapd could give root access on Linux machines Pin
Kent Sharkey13-Feb-19 10:46
staffKent Sharkey13-Feb-19 10:46 
GeneralRe: Dirty_Sock vulnerability in Canonical's snapd could give root access on Linux machines Pin
Mark_Wallace13-Feb-19 21:35
Mark_Wallace13-Feb-19 21:35 
GeneralRe: Dirty_Sock vulnerability in Canonical's snapd could give root access on Linux machines Pin
Nelek13-Feb-19 21:48
protectorNelek13-Feb-19 21:48 
NewsAndroid Things is no longer for “Things,” focuses on smart speakers and displays Pin
Kent Sharkey13-Feb-19 10:16
staffKent Sharkey13-Feb-19 10:16 
GeneralRe: Android Things is no longer for “Things,” focuses on smart speakers and displays PinPopular
Mark_Wallace13-Feb-19 21:39
Mark_Wallace13-Feb-19 21:39 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.