Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8623547
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T07:18:27+00:00 2026-06-12T07:18:27+00:00

I want to write a clojurescript function that returns a complex item like [foo

  • 0

I want to write a clojurescript function that returns a complex item like [“foo” “bar”] or (list “foo” “bar”) and I want to be able to call this function from javascript and get at the parts of the return value. How can it be done? In my case, the number of items in the vector/list/collection that I’m returning is known beforehand, and the collection should remain ordered.

Here’s my clojurescript function. I could do something differently here if it made things easier. Just don’t know what that would be.

(defn myFn [] ["foo" "bar"])

Here’s what it looks like after it has been compiled to javascript. This part is completely determined/generated by the previous bit of code. To make changes here, I’d have to know how to tweak the previous part in clojurescript.

my.ns.myFn = function myFn() {
  return cljs.core.PersistentVector.fromArray(["foo", "bar"], true)
};

When I do the following in javascript, I see an alert box pop up with [“foo” “bar”]

alert(my.ns.myFn());

But if I try the following, the alert shows “undefined” instead of “foo”.

var tmp = my.ns.myFn();
alert(tmp[0]);

What should I do differently to get the alert to show “foo” ? (Hmm. I guess I could write more clojurescript to use the value and see how that appears when compiled to javascript…)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T07:18:28+00:00Added an answer on June 12, 2026 at 7:18 am

    in clojurescript:

    (ns foo.core)
    (defn ^:export bar [x] (array 0 1 2))

    in javascript:

    var result_array = foo.core.bar(x);

    … use result_array as a normal javascript array.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to write a program in Prolog that confirms if a b-tree of
I want to write a method that when supplied an array of ints will
I want to write a function for converting BGRA in BGR. void convertBGRAViewtoBGRView( const
I want write a program that when installed, runs in background and adds a
I want write jquery code that will show form inputs after a checkbox is
I want write this sql select statment in mysql v 3.23 select * from
I have whole page HTML in my database and i want write that html
i have a value that name is brands and like this : $brands =
I want to write a pointer in c++ (or in c++0x), that will points
I want write this query in SQL Server from ( select DISTINCT salary from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.