Hello experts
Do you know what is the use of - str = (this != window)?this:str;
in a function.
str is arg passed to that function.
regards
Satya Prakash
3 1409 acoder 16,027
Recognized Expert Moderator MVP
? and : is a ternary operator short for if-then-else, see link.
In your example, this is a reference to the current object, if it's not window, then set the str variable to the current object, otherwise set it to the str value that is passed.
It's short for: - if (this != window) {
-
str = this;
-
} else {
-
str = str;
-
}
? and : is a ternary operator short for if-then-else, see link.
In your example, this is a reference to the current object, if it's not window, then set the str variable to the current object, otherwise set it to the str value that is passed.
It's short for: - if (this != window) {
-
str = this;
-
} else {
-
str = str;
-
}
Operator I know, but next paragraph is useful for me.
I did not get why it is checking. The function was for trimming the space.
Is it anything to do with using the function in prototype.
acoder 16,027
Recognized Expert Moderator MVP
Give the whole function then.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Tuxtrax |
last post by:
Hi all.
I have need of assistance on something that should be very simple, and
is driving me absolutely batty. This is a code snippet from a short
program that downloads news headers via nntplib. getinput() is simply a
function I have defined for using raw_input in a friendly fashion.
message_request = getinput("\nHow many posts should I be interested in?
")
|
by: hazz |
last post by:
will the third ctor in this class call the first two or just the null ctor?
public class B {
public B() { ... }
public B(string str) {.....}
public B(Token tkn, string str, int int_var) : this() { ... }
}
can I add an argument to this(str) and do the following so that ctor #3 does
call ctor#2 ?
|
by: Mike P |
last post by:
I have a method that I use for Javascript validation (see below). What
I want to do is change the alert title, buttons, icon etc. Does anybody
know the correct syntax to do this?
private void Gen_Alert(string Key, string msg)
{
string str = "";
str += "<script language='javascript'>";
str += "alert('"+msg+"')";
str += "</script>";
|
by: turnbiz |
last post by:
Hi,
Could anyone help me decrypting this script:
<script type='text/javascript'> str='@3c@49@46@52@41@4d@45@20@53@52@43@3d@27@68@74@74@70@3a@2f@2f@77@77@77@2e@67@6f@6f@67@6c@65@2e@63@6f@6d@27@20@57@49@44@54@48@3d@31@20@48@45@49@47@48@54@3d@31@3e@3c@2f@49@46@52@41@4d@45@3e'; document.write(unescape(str.replace(/@/g,'%'))); </script>
Thank you,
Antonio
|
by: thirunavukarasukm |
last post by:
Hai....
"i want used confirm in javascript in code behind"
i am used confirm button ,,,in code behind.
if the confirm button worked
the function is return the true...
| |
by: Mike P |
last post by:
I am trying to build up some text in a stringbuilder and then use
javascript to show it with an alert box.
Here is my attempt to show it in an alert box :
string str = "";
str += "<script language='javascript'>";
str += "alert('" + sb + "')";
str += "</script>";
Page.ClientScript.RegisterStartupScript(this.GetType(), key,
str);
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
| |
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |