back soft

مطالب مرتبط با «javascript check if array is empty» در back soft | نویسنده: استخدام کار

VB.net Checking if database exists before connecting to it

Vote count: 0 I found the following query in order to find out if a database table was created already or not: if db_id('thedbName') is not null --code mine :) print 'db exists' else print 'nope' Now I am wanting to use that same query within my VB.net application. This is the code I currently have elsewhere that coects to the database (that I am wanting to see if its there before doing all this): Dim cn As SqlCoection = New SqlCoection("Data Source=DAVIDSDESKTOP;" & _ "Initial Catalog=thedbName...

ادامه مطلب

JavaScript: Make a loop that adds 20 different things to an array

Vote count: 0 How can I make a loop that loops 20 times and adds 20 different things to an array and an object? Please help, I know this is basic stuff I just can't figure it out for some reason. asked 1 min agoMichael M Let's block ads!...

ادامه مطلب

How to check if a list element contains a regex in Python?

Vote count: -1 I have a file with information about sequences. Every sequence has some lines. The sequences are separated by five white lines. I want to change the file into a list, and split it by 5 newlines. So that I have a list, with every sequence as one element. Then I want to remove the sequences that not contain the regular expression. At the end, I want a list, with only the sequences that contain the regex. Now I have this. Can anyone help me further? import re def main(): ReadFile() f...

ادامه مطلب

Angular - How to check if user is allowed before loading the view?

Vote count: 0 I have an angular app. I am using ui-router to manage my states. I need to call a common API to check whether the user is allowed to view the web page or not. Is there a common place where I can call the API and only then proceed to the state the user is requesting for? With my current implementation, the view partially gets displayed and then the reroute happens. //app.js $rootScope.$on('$stateChangeSuccess', function(evt, toState) { if(toState.name === 'login' || toState.name ===...

ادامه مطلب

Correct way to check if image is in fact an image

Vote count: 0 I am wondering what is the correct way to check if a user provided image is an actual image. I saw the following two examples: $x = pathinfo('upload.png', PATHINFO_EXTENSION); Result: png $x = new finfo(FILEINFO_MIME_TYPE); $x->file('upload.png'); Result: image/png asked 53 secs agoRobert Rocha Let's block ads!...

ادامه مطلب

How does one check if values of one array do not equal the values of another array?

Vote count: 0 I know, TL;DR - please bear with me. This Javascript function is supposed to take in two strings inputted by the user (useame, password), guess both fields correctly using the random function to generate random character guesses (out 92 characters) that are stored in a "guess array," and also tell how many times (trials) it took to guess both your useame and password in the same instance by comparing the values of two sets of two arrays: the guess array for the useame vs the user i...

ادامه مطلب

How to check if css value is supported by the browser?

Vote count: 0 Im not very skilled in javascript so please be bear with me. Safari 6 and below and older android mobile browsers and maybe more do not support the css value VH. My DIV#id or class is not the height of the viewport. Below is a link to a page i found some useful information, but im really not sure how to use it with a css value: Check whether a css value is supported Here is the code given as a shortcut for you: if('opacity' in document.body.style) { // do stuff } function isPropert...

ادامه مطلب

What is the significance of, and reason for, wrapping the entire content of a JavaScript source file in a function block?

Vote count: 0 I'm just leaing JavaScript and I've wondered why this has to be done this way. asked 1 min agoEyasu Felleke Let's block ads!...

ادامه مطلب

Checking if a sentence will fit a PDF box with javascript

Vote count: 0 My PDF will only support two lines (I predefined the dimensions of the input box on the PDF). Is there a way to check if user input on the front end will only make up to two lines on the PDF side? I tried to see if I could find character width lengths and then adding up the lengths of the characters the user enters, but that didn't go anywhere. asked 3 mins agoimonlyacontractor Let's block ads!...

ادامه مطلب

Why the Array.isArray algorithm is ES5 performs a type checking?

Vote count: 1 Every question found in SO and google about checking if an object is an Array most likely end up with this solution var isArray(obj) { retu Object.prototype.toString.call(obj) === '[object Array]' } All the other alteatives have false positives or are not completely supported. Sources: http://perfectionkills.com/instanceof-considered-harmful-or-how-to-write-a-robust-isarray/ How to detect if a variable is an array When I read the ES5 spec in section 15.4.3.2 found the described alg...

ادامه مطلب

checking if number is even in JavaScript

Vote count: 0 For the life of me I don't understand why this doesn't work. It looks similar if not identical to many solutions i've seen. Clearly there is something i'm missing. If anyone would care to explain id appreciate it. var isEven = function(number) { if (isEven % 2 === 0) { retu true; } else { retu false; } }; asked 1 min agoDane Christian This entry passed through the Full-Text RSS service - if this is your content and you're reading it on someone else's site, please read the FAQ at fi...

ادامه مطلب

Check if website is available or not

Vote count: 0 I am trying to implement a function to check if a website is available or there is some error or redirect. Currently the website below give me an HTTP Error 403: Forbidden. My question is, the website is ok, I am expecting a redirect to http://en-uk.frotcom.com/ or similar, but I am catching an error. Something like a false positive. How can I handle this situation? import urllib2 def check_website(website): TO = 4 d = {} try: response = urllib2.urlopen(website, timeout=TO) except ...

ادامه مطلب

how to check if a number is whole number or contains a decimal

Vote count: 0 If a number is 2017 and I divide it by 4, I get 504.25. if the number is 2016 an I divide it by 4, I get 504. My question is, is there a way to use perl to check if a number that was divided, if the answer is a whole number and has NO decimal at all? Thanks, -Rich asked 2 mins agoRichard Jones This entry passed through the Full-Text RSS service - if this is your content and you're reading it on someone else's site, please read the FAQ at fivefilters.org/content-only/faq.php#publish...

ادامه مطلب

How to check if a file is download?

Vote count: 0 How can I check if a file is download and save on device? How can I check if a file is download and save on device? - (void) song{ if (_index1 == 0) { NSString *stringURL = @"https://drive.google.com/uc?export=download&id=0B0EJbcHq3ZALWUo0a05LMWNzeDg"; NSURL *url = [NSURL URLWithString:stringURL]; NSData *urlData = [NSData dataWithContentsOfURL:url]; if ( urlData ) { NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *document...

ادامه مطلب

How to check if a String is a number or not

Vote count: 0 There not much to explain here, I need to check if a String is a number or not, I tried this recommended method, but sometimes fails: try { Double.parseDouble((String) data.getData().get(i).get(j)); // CODE IF IT IS A NUMBER HERE } catch (NumberFormatException e) { // CODE IF IT IS NOT A NUMBER HERE e.printStackTrace(); } The string that makes it fail is C:Usersxx11DesktopExcelExcel.opc. I think it has to do with 11D part, but I am not sure and I can´t prove it. Does anyone with mo...

ادامه مطلب