10 examples of 'jquery tostring' in JavaScript

Every line of 'jquery tostring' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
86function jQueryToString($obj) {
87 var i
88 ,stringArray = []
89 ;
90 for (i=0; i<$obj.length; i++) {
91 stringArray.push( elementToString($obj[i]) );
92 }
93
94 return '$('+ stringArray.join(', ') +')';
95}
112export function toString(obj: any): string {
113 if (obj && obj.toString) {
114 // Arrays might hold objects with "null" prototype So using
115 // Array.prototype.toString directly will cause an error Iterate through
116 // all the items and handle individually.
117 if (isArray(obj)) {
118 return ArrayJoin.call(ArrayMap.call(obj, toString), ',');
119 }
120 return obj.toString();
121 } else if (typeof obj === 'object') {
122 return OtS.call(obj);
123 } else {
124 return obj + emptyString;
125 }
126}
120toString() {
121 try {
122 return String(this[_jsObject]);
123 } catch (e) {
124 return super.toString();
125 }
126
127}
132toString() {
133 var result = '<' + this.tagName;
134 for (var name in this.attributes) {
135 if (hasOwnProp.call(this.attributes, name)) {
136 result += ' ' + name + '="' + this.attributes[name] + '"';
137 }
138 }
139
140 if (this.selfClosing) {
141 result += ' />';
142 } else {
143 result += '>';
144 for (var i = 0, l = this.childNodes.length; i < l; i++) {
145 result += this.childNodes[i].toString();
146 }
147 result += '';
148 }
149
150 return result;
151}
67function toStr(o) {
68 return o.toString();
69}
35function ToString( obj ) {
36 return obj +"";
37}
117function toString(object) {
118 switch (getType(object)) {
119 case "string":
120 if (object === "") {
121 return "";
122 }
123
124 if (object.length > 100) {
125 //truncate it
126 object = object.substring(0, 50) + "..." + object.substring(object.length - 50);
127 }
128
129 return "\"" + object + "\"";
130 case "number":
131 case "boolean":
132 return object;
133 case "null":
134 return "";
135 case "undefined":
136 return "";
137 case "object":
138 if (object instanceof RegExp) {
139 return "[Object(RegExp:" + object.toString() + ")]";
140 }
141
142 return "[Object(" + getFunctionName(object.constructor.toString()) + ")]";
143 case "array":
144 return "[Array(length=" + object.length + ")]";
145 case "function":
146 try {
147 return "[Function(" + getFunctionName(object.toString()) + ")]";
148 } catch (e) {
149 return "[Function]";
150 }
151 }
152
153 throw "getType() returned an invalid value";
154}
16function arrToString(_arr)
17{
18 var _t = "[{id:\"" + _arr[0].id + "\",value:\"" + _arr[0].value + "\"}";
19 for(var i = 1;i < _arr.length;i++)
20 {
21 _t += ",{id:\"" + _arr[i].id + "\",value:\"" + _arr[i].value + "\"}";
22 }
23 _t += "]";
24 return _t;
25}
22function elemToString(elem) {
23 var tagStr = elem.tagName ? elem.tagName.toLowerCase() : elem.toString();
24 var classStr = elem.className ? '.' + (elem.className) : '';
25 var result = tagStr + classStr;
26 return elem.tagName ? ['\'', '\''].join(result) : result;
27}
197URL.prototype.toString = function toString(stringify) {
198 if (!stringify || 'function' !== typeof stringify) stringify = qs.stringify;
199
200 var query
201 , url = this
202 , result = url.protocol +'//';
203
204 if (url.username) {
205 result += url.username;
206 if (url.password) result += ':'+ url.password;
207 result += '@';
208 }
209
210 result += url.hostname;
211 if (url.port) result += ':'+ url.port;
212
213 result += url.pathname;
214
215 query = 'object' === typeof url.query ? stringify(url.query) : url.query;
216 if (query) result += '?' !== query.charAt(0) ? '?'+ query : query;
217
218 if (url.hash) result += url.hash;
219
220 return result;
221};

Related snippets