Guest User

Untitled

a guest
Oct 19th, 2017
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.25 KB | None | 0 0
  1. if(arrayName[index]==""){
  2. // do stuff
  3. }
  4.  
  5. if (index < array.length) {
  6. // do stuff
  7. }
  8.  
  9. if (typeof array[index] !== 'undefined') {
  10.  
  11. if (typeof array[index] !== 'undefined' && array[index] !== null) {
  12.  
  13. if (array[index] != null) {
  14. // The == and != operator consider null equal to only null or undefined
  15.  
  16. if(arrayName.length > 0){
  17. //or **if(arrayName.length)**
  18. //this array is not empty
  19. }else{
  20. //this array is empty
  21. }
  22.  
  23. if(!arrayName[index]){
  24. // do stuff
  25. }
  26.  
  27. if(array && array.length){
  28. // not empty
  29. } else {
  30. // empty
  31. }
  32.  
  33. Objects.keys(__array__).length
  34.  
  35. if(arrayName.length > index && arrayName[index] !== null) {
  36. //arrayName[index] has a value
  37. }
  38.  
  39. if(typeof arr ==='object' && arr instanceof Array ){
  40. if(!arr.length){
  41. println 'empty'
  42. }else{
  43. printn 'not Empty'
  44. }
  45.  
  46. }else{
  47. println 'Null'
  48. }
  49.  
  50. if(!arr.clean().length){return 'is null'}
  51.  
  52. Array.prototype.clean=function(){return this.filter(function(e){return (typeof e !=='undefined')&&(e!= null)&&(e!='')})}
  53.  
  54. function isEmptyEl(array, i) {
  55. return !(array[i]);
  56. }
  57.  
  58. if (isEmptyEl(arrayName, indexVal)) {
  59. console.log('arrayName[' + indexVal + '] is empty');
  60. }
  61.  
  62. Uncaught ReferenceError: arrayName is not defined
  63. at <anonymous>:2:15
  64. at Object.InjectedScript._evaluateOn (<anonymous>:895:140)
  65. at Object.InjectedScript._evaluateAndWrap (<anonymous>:828:34)
  66. at Object.InjectedScript.evaluate (<anonymous>:694:21)
  67.  
  68. index in array;
  69. array.hasOwnProperty(index);
  70.  
  71. if (array[index] != null)
  72.  
  73. if(_.has(req,'documents')){
  74. if (req.documents.length)
  75. _.forEach(req.documents, function(document){
  76. records.push(document);
  77. });
  78. } else {
  79. }
  80.  
  81. if(typeof arrayName[index]==="undefined"){
  82. //the index is not in the array
  83. }
  84.  
  85. if(typeof arrayName[index]==="undefined"||arrayName[index]){
  86. //the index is not defined or the value an empty value
  87. }
  88.  
  89. render: function (data, type, full) {
  90. if (full.properties.length !== 0) {
  91. // do stuff
  92. }
  93. }
  94.  
  95. var pets = ['dog', undefined, 'cat', null];
  96.  
  97. console.log(_.isEmpty(pets[1])); // true
  98. console.log(_.isEmpty(pets[3])); // true
  99. console.log(_.isEmpty(pets[4])); // false
  100.  
  101. _.map( pets, (pet, index) => { console.log(index + ': ' + _.isEmpty(pet) ) });
Add Comment
Please, Sign In to add comment